/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2025-02-22 14:51:07
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2025-02-22 14:53:15
 * @FilePath: /thread/thread_control/test1.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#include<iostream>
#include<pthread.h>
#include<unistd.h>
#include<string>
using namespace std;

void* threadrun(void* args)
{
    string name=static_cast<const char*> (args);

    while(true)
    {
        cout<<name<<" is running , tid: "<<pthread_self()<<endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadrun,(void*)"thread-1");

    cout<<" new thread tid: "<<tid<< endl;
    pthread_join(tid,nullptr);
    return 0;
}